{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from scipy.stats import ttest_ind, levene"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "def scoreParser(s):\n",
    "    return [float(i.split()[-1]) for i in s.strip().split('\\n')]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "oracle = scoreParser('''\n",
    "compress                      iteration 1    240000         240000         2712.59        678.15\n",
    "compress                      iteration 2    240000         240000         2709.13        677.28\n",
    "compress                      iteration 3    240000         240000         2737.84        684.46\n",
    "compress                      iteration 4    240000         240000         2705.39        676.35\n",
    "compress                      iteration 5    240000         240000         2773.42        693.35\n",
    "compress                      iteration 6    240000         240000         2668.66        667.16\n",
    "compress                      iteration 7    240000         240000         2657.45        664.36\n",
    "compress                      iteration 8    240000         240000         2643.21        660.80\n",
    "compress                      iteration 9    240000         240000         2666.88        666.72\n",
    "compress                      iteration 10   240000         240000         2668.32        667.08\n",
    "compress                      iteration 11   240000         240000         2683.72        670.93\n",
    "compress                      iteration 12   240000         240000         2686.89        671.72\n",
    "compress                      iteration 13   240000         240000         2687.97        671.99\n",
    "compress                      iteration 14   240000         240000         2698.49        674.62\n",
    "compress                      iteration 15   240000         240000         2705.24        676.31\n",
    "''')\n",
    "Temurin = scoreParser('''\n",
    "compress                      iteration 1    240000         240000         2715.53        678.88\n",
    "compress                      iteration 2    240000         240000         2709.25        677.31\n",
    "compress                      iteration 3    240000         240000         2704.85        676.21\n",
    "compress                      iteration 4    240000         240000         2715.26        678.82\n",
    "compress                      iteration 5    240000         240000         2709.50        677.38\n",
    "compress                      iteration 6    240000         240000         2708.65        677.16\n",
    "compress                      iteration 7    240000         240000         2718.06        679.51\n",
    "compress                      iteration 8    240000         240000         2709.23        677.31\n",
    "compress                      iteration 9    240000         240000         2792.29        698.07\n",
    "compress                      iteration 10   240000         240000         2772.36        693.09\n",
    "compress                      iteration 11   240000         240000         2792.81        698.20\n",
    "compress                      iteration 12   240000         240000         2786.46        696.62\n",
    "compress                      iteration 13   240000         240000         2790.96        697.74\n",
    "compress                      iteration 14   240000         240000         2793.95        698.49\n",
    "compress                      iteration 15   240000         240000         2795.06        698.76\n",
    "''')\n",
    "Bellsoft = scoreParser('''\n",
    "compress                      iteration 1    240000         240000         2737.99        684.50\n",
    "compress                      iteration 2    240000         240000         2729.82        682.45\n",
    "compress                      iteration 3    240000         240000         2724.39        681.10\n",
    "compress                      iteration 4    240000         240000         2715.64        678.91\n",
    "compress                      iteration 5    240000         240000         2719.60        679.90\n",
    "compress                      iteration 6    240000         240000         2720.41        680.10\n",
    "compress                      iteration 7    240000         240000         2730.70        682.67\n",
    "compress                      iteration 8    240000         240000         2690.86        672.72\n",
    "compress                      iteration 9    240000         240000         2764.42        691.10\n",
    "compress                      iteration 10   240000         240000         2757.07        689.27\n",
    "compress                      iteration 11   240000         240000         2774.10        693.53\n",
    "compress                      iteration 12   240000         240000         2756.02        689.00\n",
    "compress                      iteration 13   240000         240000         2764.45        691.11\n",
    "compress                      iteration 14   240000         240000         2764.59        691.15\n",
    "compress                      iteration 15   240000         240000         2764.30        691.07\n",
    "''')\n",
    "Bisheng = scoreParser('''\n",
    "compress                      iteration 1    240000         240000         2589.49        647.37\n",
    "compress                      iteration 2    240000         240000         2622.27        655.57\n",
    "compress                      iteration 3    240000         240000         2611.33        652.83\n",
    "compress                      iteration 4    240000         240000         2605.32        651.33\n",
    "compress                      iteration 5    240000         240000         2612.51        653.13\n",
    "compress                      iteration 6    240000         240000         2649.15        662.29\n",
    "compress                      iteration 7    240000         240000         2656.74        664.18\n",
    "compress                      iteration 8    240000         240000         2653.27        663.32\n",
    "compress                      iteration 9    240000         240000         2659.38        664.85\n",
    "compress                      iteration 10   240000         240000         2657.91        664.48\n",
    "compress                      iteration 11   240000         240000         2654.81        663.70\n",
    "compress                      iteration 12   240000         240000         2653.45        663.36\n",
    "compress                      iteration 13   240000         240000         2654.64        663.66\n",
    "compress                      iteration 14   240000         240000         2656.29        664.07\n",
    "compress                      iteration 15   240000         240000         2662.98        665.75\n",
    "''')\n",
    "Dragonwell = scoreParser('''\n",
    "compress                      iteration 1    240000         240000         2688.59        672.15\n",
    "compress                      iteration 2    240000         240000         2692.88        673.22\n",
    "compress                      iteration 3    240000         240000         2720.37        680.09\n",
    "compress                      iteration 4    240000         240000         2712.36        678.09\n",
    "compress                      iteration 5    240000         240000         2733.19        683.30\n",
    "compress                      iteration 6    240000         240000         2769.88        692.47\n",
    "compress                      iteration 7    240000         240000         2780.51        695.13\n",
    "compress                      iteration 8    240000         240000         2785.72        696.43\n",
    "compress                      iteration 9    240000         240000         2788.66        697.17\n",
    "compress                      iteration 10   240000         240000         2788.07        697.02\n",
    "compress                      iteration 11   240000         240000         2785.60        696.40\n",
    "compress                      iteration 12   240000         240000         2786.39        696.60\n",
    "compress                      iteration 13   240000         240000         2789.81        697.45\n",
    "compress                      iteration 14   240000         240000         2790.98        697.74\n",
    "compress                      iteration 15   240000         240000         2784.83        696.21\n",
    "''')\n",
    "Kona = scoreParser('''      \n",
    "compress                      iteration 1    240000         240000         2664.85        666.21         \n",
    "compress                      iteration 2    240000         240000         2702.75        675.69         \n",
    "compress                      iteration 3    240000         240000         2706.60        676.65         \n",
    "compress                      iteration 4    240000         240000         2709.98        677.50         \n",
    "compress                      iteration 5    240000         240000         2736.24        684.06         \n",
    "compress                      iteration 6    240000         240000         2762.78        690.70         \n",
    "compress                      iteration 7    240000         240000         2817.31        704.33         \n",
    "compress                      iteration 8    240000         240000         2834.28        708.57         \n",
    "compress                      iteration 9    240000         240000         2833.27        708.32         \n",
    "compress                      iteration 10   240000         240000         2826.15        706.54         \n",
    "compress                      iteration 11   240000         240000         2838.10        709.52         \n",
    "compress                      iteration 12   240000         240000         2841.51        710.38         \n",
    "compress                      iteration 13   240000         240000         2835.76        708.94         \n",
    "compress                      iteration 14   240000         240000         2774.24        693.56         \n",
    "compress                      iteration 15   240000         240000         2776.13        694.03   \n",
    "''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "scores = {'Oracle': oracle, 'Temurin': Temurin,  'Liberica': Bellsoft,\n",
    "          'DragonWell':  Dragonwell, 'Kona': Kona, 'Bisheng': Bisheng}\n",
    "idx = ['Oracle', 'Temurin', 'Liberica', 'DragonWell', 'Kona', 'Bisheng']\n",
    "df = pd.DataFrame(index=idx, columns=idx)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Oracle': [678.15,\n",
       "  677.28,\n",
       "  684.46,\n",
       "  676.35,\n",
       "  693.35,\n",
       "  667.16,\n",
       "  664.36,\n",
       "  660.8,\n",
       "  666.72,\n",
       "  667.08,\n",
       "  670.93,\n",
       "  671.72,\n",
       "  671.99,\n",
       "  674.62,\n",
       "  676.31],\n",
       " 'Temurin': [678.88,\n",
       "  677.31,\n",
       "  676.21,\n",
       "  678.82,\n",
       "  677.38,\n",
       "  677.16,\n",
       "  679.51,\n",
       "  677.31,\n",
       "  698.07,\n",
       "  693.09,\n",
       "  698.2,\n",
       "  696.62,\n",
       "  697.74,\n",
       "  698.49,\n",
       "  698.76],\n",
       " 'Liberica': [684.5,\n",
       "  682.45,\n",
       "  681.1,\n",
       "  678.91,\n",
       "  679.9,\n",
       "  680.1,\n",
       "  682.67,\n",
       "  672.72,\n",
       "  691.1,\n",
       "  689.27,\n",
       "  693.53,\n",
       "  689.0,\n",
       "  691.11,\n",
       "  691.15,\n",
       "  691.07],\n",
       " 'DragonWell': [672.15,\n",
       "  673.22,\n",
       "  680.09,\n",
       "  678.09,\n",
       "  683.3,\n",
       "  692.47,\n",
       "  695.13,\n",
       "  696.43,\n",
       "  697.17,\n",
       "  697.02,\n",
       "  696.4,\n",
       "  696.6,\n",
       "  697.45,\n",
       "  697.74,\n",
       "  696.21],\n",
       " 'Kona': [666.21,\n",
       "  675.69,\n",
       "  676.65,\n",
       "  677.5,\n",
       "  684.06,\n",
       "  690.7,\n",
       "  704.33,\n",
       "  708.57,\n",
       "  708.32,\n",
       "  706.54,\n",
       "  709.52,\n",
       "  710.38,\n",
       "  708.94,\n",
       "  693.56,\n",
       "  694.03],\n",
       " 'Bisheng': [647.37,\n",
       "  655.57,\n",
       "  652.83,\n",
       "  651.33,\n",
       "  653.13,\n",
       "  662.29,\n",
       "  664.18,\n",
       "  663.32,\n",
       "  664.85,\n",
       "  664.48,\n",
       "  663.7,\n",
       "  663.36,\n",
       "  663.66,\n",
       "  664.07,\n",
       "  665.75]}"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scores"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Oracle</th>\n",
       "      <th>Temurin</th>\n",
       "      <th>Liberica</th>\n",
       "      <th>DragonWell</th>\n",
       "      <th>Kona</th>\n",
       "      <th>Bisheng</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Oracle</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>*</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Temurin</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Liberica</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>*</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>DragonWell</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Kona</th>\n",
       "      <td>*</td>\n",
       "      <td></td>\n",
       "      <td>*</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>*</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Bisheng</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>*</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           Oracle Temurin Liberica DragonWell Kona Bisheng\n",
       "Oracle                                           *        \n",
       "Temurin                                                   \n",
       "Liberica                                         *        \n",
       "DragonWell                                                \n",
       "Kona            *                *                       *\n",
       "Bisheng                                          *        "
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ALPHA = 0.05\n",
    "for i in range(6):\n",
    "    for j in range(6):\n",
    "        data1, data2 = scores[idx[i]], scores[idx[j]]\n",
    "        p_value = ttest_ind(\n",
    "            data1, data2, equal_var=levene(data1, data2).pvalue < ALPHA).pvalue\n",
    "        # df.iloc[i, j] = levene(data1, data2).pvalue\n",
    "        # df.iloc[i, j] = pvalue\n",
    "        if p_value < ALPHA:\n",
    "            df.iloc[i, j] = '*'\n",
    "        else:\n",
    "            df.iloc[i, j] = ''\n",
    "df = df.where(df.isna(), df.T)\n",
    "df"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "analyze",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.3"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
